﻿@model StudentViewModel
@{
    ViewData["Title"] = "Index";
}
@* <form action="/Csrf/Submit" method="post">
    @Html.AntiForgeryToken();  <!--表单上添加防伪Token，提交时会携带这个Token -->
    <table class="table">
        <tr>
            <td>@Html.LabelFor(p=>p.UserName)</td>
            <td>@Html.TextBoxFor(p=>p.UserName)</td>
        </tr>
        <tr>
            <td>@Html.LabelFor(p=>p.Email)</td>
            <td>@Html.TextBoxFor(p=>p.Email)</td>
        </tr>
        <tr>
            <td>@Html.LabelFor(p=>p.Desc)</td>
            <td>@Html.TextAreaFor(p=>p.Desc)</td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="提交" />
            </td>
        </tr>
    </table>
</form> *@

<!--使用"标签助手"会自动的表单，会被自动添加防伪Token -->
<!--这个防伪Token其实是一个隐藏域-->
<form asp-action="Submit" asp-controller="Csrf" method="post">
    <table class="table">
        <tr>
            <td><label asp-for="UserName"></label></td>
            <td><input asp-for="UserName" /></td>
        </tr>
        <tr>
            <td><label asp-for="Email"></label></td>
            <td><input asp-for="Email" /></td>
        </tr>
        <tr>
            <td><label asp-for="Desc"></label></td>
            <td><input asp-for="Desc" /></td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="提交" />
            </td>
        </tr>
    </table>
</form>

